package com.framework.network.annotations

import java.lang.annotation.Documented
import java.lang.reflect.Method

/**
 * @ClassName: SetTimeOut
 * @Description: 自定义注解，设置是否添加公共参数
 * @Author: you
 */
@Documented
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.PROPERTY_SETTER
)
@Retention(AnnotationRetention.RUNTIME)
annotation class CommonParams(val isAddCommonParam: Boolean = true)

/**
 * 获取是否添加公共参数的注解
 */
fun getCommonParams(method: Method): CommonParams? {
    val annotations = method.annotations
    for (annotation in annotations) {
        if (annotation is CommonParams) {
            return annotation
        }
    }
    return null
}

/**
 * 获取结果
 */
fun getCommonParamsParameter(commonParams: CommonParams): Boolean {
    return commonParams.isAddCommonParam
}
